package day10.ZiXi;

import java.util.Collection;
import java.util.HashMap;

public class MapDemo03 {
    public static void main(String[] args) {
        //创建集合对象
        HashMap<String,String> hm = new HashMap<>();
        ////添加元素
        hm.put("张无忌","赵敏");
        hm.put("郭靖","黄蓉");
        hm.put("杨过","小龙女");
        //V   get(Object key)根据键获取值
        //System.out.println(hm.get("杨过"));
        //System.out.println(hm.get("张三丰"));
        //Set<K>   keySet()获取所有键的集合
        /*Set<String> ks = hm.keySet();
        for (String k : ks) {
            System.out.println(k);*/
        //Collection<V>   values()获取所有值的集合
        Collection<String> va = hm.values();
        for (String s : va) {
            System.out.println(s);

        }
    }
}
